package com.revenco.bi.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Controller;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus;

import com.revenco.bi.controller.basecontroller.Exceptions;
import com.revenco.bi.model.KpiPeriod;
import com.revenco.bi.service.DemoService;

@Controller
public class Demo extends Exceptions{
	@Autowired
	private DemoService demoService;

	@RequestMapping(value = "/demo", method = RequestMethod.GET)
	@ResponseBody
	public List<KpiPeriod> demoGet() throws Exception{
		List<KpiPeriod> list = demoService.getAll();
		for (KpiPeriod kpiPeriod : list) {
			System.out.println(kpiPeriod.getPeriodName());
		}
		return list;
		
	}
	
	@RequestMapping(value = "/demo", method = RequestMethod.POST)
	@ResponseBody
	public Map<String, String> demoPost(@RequestBody Map<String, String> params) throws Exception{
		String keyword = params.get("keyword");
		System.out.println(keyword);
		Map<String, String> map = new HashMap<String, String>();
		map.put("key", keyword);
		return map;
	}
	@RequestMapping(value = "/demo/{id}", method = RequestMethod.DELETE)
	@ResponseStatus(HttpStatus.OK)
	public void demoDelete(@PathVariable String id) throws Exception{
		System.out.println(id);

	}
	
}
